<template>
	<view>
		<view class="companyInfo">
			<view>
				<view class="hvl-txt-link" @click="goindex">返回首页</view>
			</view>
			<view>
				<view class="hvl-txt-link" @click="totemperature">查看温测</view>
			</view>
		</view>
		<view class="uni-padding-wrap">
			<view class="uni-flex uni-column table-content">
				<view class="uni-flex uni-row table-header">

					<view class="flex-item table-column" style="width: 20%;">姓名</view>
					<view class="flex-item table-column" style="width: 20%;">电话</view>
					<view class="flex-item table-column" style="width: 20%;">发热</view>
					<view class="flex-item table-column" style="width: 20%;">湖北籍</view>
					<view class="flex-item table-column" style="width: 20%;">本地</view>	
				</view>
				<view ref='_list' class="flex-item flex-item-V" v-for="(list, index) in lists" v-bind:key="index">

					<view class="uni-flex uni-row table-body">
						<view class="flex-item table-column hvl-txt-link" style="width: 20%;" @click="goDetail(list)">{{list.Name}}</view>
						<view class="flex-item table-column" style="width: 20%;">{{list.Tel}}</view>
						<view class="flex-item table-column" style="width: 20%;"><span v-if="list.IsHubei ==='0'">否</span>
							<span v-if="list.IsHubei ==='1'">是</span></view>
						<view class="flex-item table-column" style="width: 20%;"><span v-if="list.IsTouch ==='0'">否</span>
							<span v-if="list.IsTouch ==='1'">是</span></view>
						<view class="flex-item table-column" style="width: 20%;">
							<span v-if="list.Native ==='0'">否</span>
							<span v-if="list.Native ==='1'">是</span>
						</view>
					</view>
				</view>
				<view v-if="list.length === 0" class="table-body" style="text-align: center;">
					暂无数据
				</view>
			</view>
			<view class="pageList">
				<uni-pagination :total="totalRow" :current="page" :pageSize="size" @change="changePage"></uni-pagination>
			</view>
			<view class="pageDesc">总共{{totalRow}}条</view>
		</view>

		<uni-popup ref="popup" type="center">
			<view class="popupCon">
				<view>姓名：{{currItem.Name}}</view>
				<view>电话：{{currItem.Tel}}</view>
				<view>身份证：{{currItem.CardId}}</view>
				<view>
					是否为湖北籍贯：
					<span v-if="currItem.IsHubei ==='1'">否</span>
					<span v-if="currItem.IsHubei ==='0'">是</span>
				</view>
				<view>
					是否发热：
					<span v-if="currItem.IsTouch ==='1'">否</span>
					<span v-if="currItem.IsTouch ==='0'">是</span>
				</view>
				<view>
					是否为本地户籍：
					<span v-if="currItem.Native ==='1'">否</span>
					<span v-if="currItem.Native ==='0'">是</span>
				</view>
				<view>现居住地：{{currItem.NowAddress}}</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		pagePerson
	} from '../../../api/index.js';
	import uniPagination from '@dcloudio/uni-ui/lib/uni-pagination/uni-pagination.vue';
	import uniPopup from "@dcloudio/uni-ui/lib/uni-popup/uni-popup.vue";
	import {
		xlsxUtil
	} from '../../../common/xlsxUtil.js'
	import {
		excelConfig
	} from '../../../common/hvl-excel-config.js'
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import moment from 'moment';
	export default {
		components: {
			uniPagination,
			uniPopup
		},
		data() {
			return {
				manager_id: wx.getStorageSync("SysId"),
				lists: [],
				total: 0,
				page: 1,
				size: 15,
				totalRow:'',
				totalPage:'1',
				formData: {},
				json_data: [],
				currItem: {},
				excelConf: excelConfig
			}
		},
		onLoad: function(option) {
			console.log(option.p);
			this.page = option.p || 1;
		},
		computed: mapState(['hasLogin', 'userInfo']),
		methods: {
			// ...mapMutations(['logout']),
			goindex: function() {
				uni.navigateTo({
					url: '../../index/index'
				});
			},
			totemperature: function() {
				uni.navigateTo({
					url: './enterprise1'
				});
			},
			getExcelData: function(excelObj) {
				xlsxUtil.init(excelObj.funcName, {}, excelObj.showFields, 'downlink', excelObj.downloadName);
				xlsxUtil.getExcelData();
			},
			load() {
				var datelist = {
					page_number: '1',
					page_size:'15',
					company_id: wx.getStorageSync("manage_company_id")
				}
				var datelist = pagePerson(datelist)
				Promise.resolve(datelist).then(function(result) {
					if (result.code == '0') {
						wx.setStorageSync('listdata', result.data)
					}
				})
				var _list = wx.getStorageSync('listdata')
				this.lists = _list.list
				console.log(this.lists)
				this.list = aaa;

				console.log(wx.getStorageSync('listdata'))
			},
			goDetail: function(d) {
				this.currItem = d;
				this.$refs.popup.open();
			},
			changePage: function(e) {
				this.page = e.current;
				this.formData.page = e.current;
				this.get(this.page);
			},
			get(index) {
				var that =this
				var datelist={
					page_number:index,
					company_id:this.manager_id
				}
				var datelist=pageTemperature(datelist)
				Promise.resolve(datelist).then(function(result) {
					if (result.code == '0') {
						wx.setStorageSync('listdata2', result.data)
						that.lists = result.data.list
						that.totalPage =result.data.totalPage
						that.totalRow =result.data.totalRow
					}
				})
			}
		},
		mounted() {
			if (wx.getStorageSync("manage_company_id") != '') {
				this.manager_id = wx.getStorageSync("manage_company_id")
			}
			if (wx.getStorageSync("SysId") != '') {
				this.manager_id = wx.getStorageSync("SysId")
			}
			var that = this
			var datelist = {
				page_number: '1',
				page_size:'15',
				company_id: this.manager_id
			}
			var datelist = pagePerson(datelist)
			Promise.resolve(datelist).then(function(result) {
				if (result.code == '0') {
					wx.setStorageSync('listdata', result.data)
					that.lists = result.data.list
					that.totalPage =result.data.totalPage
					that.totalRow =result.data.totalRow
				}
			})

		}
	}
</script>

<style>
	.companyInfo {
		margin-top: 20rpx;
		display: flex;
		justify-content: space-between;
		padding: 0 30rpx;
	}

	.popupCon {
		background-color: #FFFFFF;
		padding: 30rpx 40rpx;
	}

	,

	.uni-form-item .title {
		padding: 14rpx 0;
		width: 180rpx;
		text-align: right;
		background-color: #FFFFFF;
	}

	.table-content {
		padding: 10rpx 0;
	}

	.table-column {
		text-align: center;
		line-height: 40rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
	}

	.table-header {
		justify-content: space-between;
		color: #909399;
		background-color: #FFFFFF;
		border-top: 1px solid #ebeef5;
		border-bottom: 1px solid #ebeef5;
		padding: 18rpx 0;
	}

	.table-body {
		justify-content: space-between;
		background-color: #FFFFFF;
		border-bottom: 1px solid #ebeef5;
		padding: 10rpx 0;
		color: #888888;
	}

	.pageList {
		background-color: #FFFFFF;
		margin-top: 20rpx;

	}

	.pageDesc {
		text-align: center;
		margin-top: 10rpx;
		margin-bottom: 40rpx;
		font-size: 14px;
	}
</style>
